home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
Mops 2.7
/
Mops source
/
Nuc source
/
Setup.asm
< prev
Wrap
Assembly Source File
|
1995-11-24
|
4KB
|
155 lines
; This file contains the code which initializes the system.
jtbl run
ref main
ipath "::mops source:nuc source:"
IF1
incl "macrox.asm"
incl "globals.psm"
ENDI
; ========================
sbase equ *+32766
bra.s run
maxDic dc.l 700000 ; These correspond to the quantities in the
minHeap dc.l 20000 ; main dictionary with the same names.
dicSize dc.l 0 ; We compute DicSize here, and the others
StkSpace dc.l 50000 ; are set up by Install. Just to be safe,
RstkSpace dc.l 6000 ; When Main starts, it copies them from here
; to the main dic. These values are the
; defaults, and will be the initial values
; displayed in the Install dialog the first
; time it's run using a freshly assembled
; nucleus.
installed dc.b 0 ; Set NZ by Install if this is an installed
; application
spare dc.b 0
run nop ; Space for a debugger trap if necessary
; NOTE: all the above quantities are at offsets from the start which are ASSUMED by
; Install. Don't move anything without checking Install!!
move.l CurrentA5,a5 ; In case we're restarting after a crash
lea sbase,a3 ; Make us addressable
move.l #$CDCD,-(a7) ; Safety margin on return stack, with markers.
move.l #$ABAB,-(a7) ; These are easy to recognize in Macsbug,
; and the top one is odd in case we
; try to use it as a return address.
move.l a7,d7 ; Leave R0 value in D7 for Main
move.l a7,a0
sub.l RstkSpace,a0
clr.l -(a0)
clr.l -(a0)
move.l #$CD,-(a0) ; Set up data stack:
move.l #$AB,-(a0) ; Safety margin on data stack, with markers
move.l a0,a6
move.l a0,d6 ; Leave S0 value in D6 for Main
sub.l StkSpace,A0 ; Reserve data stack space
move.l a0,d4 ; Save addr for after _InitGraf etc.
exg a6,a7 ; Setup for system calls
pea -4(a5)
_InitGraf
move.l d4,a0
_SetApplLimit
_MaxApplZone
_MaxMem ; Leaves D0 = max available heap block size
move.l d0,d3 ; Save in D3 for later
_InitFonts
; MOVE.L #$0000FFFF,D0
; _FlushEvents ; (whichMask,stopMask:EventMask)
; Hmmm. Do we really need to flush
; events? Typeahead could be
; useful.
_InitWindows
_TeInit
_InitMenus
_InitCursor
; Now we check the availability of some traps:
MOVE.W #$9F,D0
_GetTrapAddressTool
move.l a0,a4 ; A4 = unimplemented trap addr
MOVEQ #$60,D0 ; Get WaitNextEvent trap addr
_GetTrapAddressTool
cmp.l a0,a4 ; If different from unimpl, WNE is available.
sne d5
beq.s .su1
moveq #-1,d0 ; And if WNE is available, so is StripAddress
_StripAddress ; Get StripAddress mask to D0
bra.s .su2
.su1 move.l Lo3Bytes,d0 ; If no WNE, SA mask is Lo3Bytes
.su2 move.l d0,d4 ; Leave in D4 for Main
lsl.l #8,d5 ; Now we set various flags in D5 for Main
move.l #$198,d0 ; HWpriv trap number
_GetTrapAddressOS
cmp.l a0,a4 ; NE-> HWpriv is available
sne d5
lsl.l #8,d5
move.l #$1AD,d0 ; Gestalt trap number
_GetTrapAddressOS
cmp.l a0,a4 ; NE-> Gestalt is available
sne d5
beq.s .noGest
move.l #'proc',d0 ; If so, we'll use it to get info
dc.w $A1AD ; _Gestalt
bne.s .noGest
move.l a0,-(a7) ; Proc# to stack for Main
move.l #'fpu ',d0
dc.w $A1AD ; _Gestalt
bne.s .noFPU ; If call failed, assume no FPU
move.l a0,-(a7) ; FPU status to stack for Main
beq.s .su3
clr.l -(a7) ; If FPU present, initialize it as per
clr.l -(a7) ; Tech Note 146.
dc.w $F21F,$9800 ; fmovem (a7)+,FPCR/FPSR
bra.s .su3
.noGest moveq #1,d0 ; No Gestalt, or call failed.
move.l d0,-(a7) ; Assume processor is 68000.
.noFPU clr.l -(a7) ; And no FPU
.su3 tst.b installed-sbase(a3)
bne callMain ; If this is an installed application, skip
; the next bit
; Now we set the size of the main (CODE 2) resource
sub.l MinHeap,d3 ; Subtract minimum heap requirement
move.l MaxDic,d0 ; Is remaining heap bigger than max
cmp.l d0,d3 ; dic size needed?
blt.s .1 ; No - grab it all
move.l d0,d3 ; Yes - only grab max size needed
.1 move.l d3,dicSize-sbase(a3) ; Final dic size
clr.l -(sp)
move.l #'CODE',-(a7)
move.w #2,-(a7)
_GetResource
move.l (a7),a0 ; A0 = handle to CODE 2 (Main)
_Hunlock ; Unlock it just in case, since we're
move.l (a7),a0 ; going to expand it
move.l d3,d0
; add.l #nucTop-start,d0 ; Add nucleus size to dic requirement
_SetHandleSize ; Set CODE 2 to total size
tst.l d0 ; Did we get the memory?
beq.s .2 ; Yes
move.w #3,-(a7)
_SysBeep
_ExitToShell ; No - something's terribly wrong - virus?
.2 move.l (a7)+,a0 ; Lock CODE 2 to make sure it doesn't get
_Hlock ; purged since we've expanded it
callMain
lea maxDic,a2
jmp main